\section{Random Other Things}

This video will cover a few more random topics that come up when typesetting documents in \LaTeX.

\begin{center}
  \fbox{\includegraphics[width=0.85\linewidth]{img-9-1}}
\end{center}

A lot of challenges arise when thinking about the spacing. As we've seen, \LaTeX\ naturally tries to stretch out the text to fill the line. Sometimes in those calculations, it will decide to split something in a way that you don't want. It can be distracting to the read if you're talking about the real number $x$, but the $x$ is orphaned on the next line. To keep two text objects together, you can use a tilde in between them. This tilde is called a non-breaking space. This will force \LaTeX\ to find another way to space things out but without putting a line break there.

\begin{center}
  \fbox{\includegraphics[width=0.85\linewidth]{img-9-2}}
\end{center}

\LaTeX\ is quite good at hyphenation, and so it's unlikely that you will need to manually adjust this. But just in case, here is how you can control the hyphenation. If \LaTeX\ doesn't know how to hyphenate a particular word, it may let the word spill into the margin or it may move the word to the next line and pad the spacing above to spread out the text. When this happens, you can help \LaTeX\ out by giving it an optional hyphenation scheme. These optional hyphens are denoted by \verb|\-|.

\begin{center}
  \fbox{\includegraphics[width=0.85\linewidth]{img-9-3}}
\end{center}

One other minor issue that arises is in the spacing after abbreviations and titles. \LaTeX\ will automatically put a larger space after every period, treating it like the end of a sentence. But if you wanted a regular space, you can put a backslash-space immediately after the period. The difference is subtle in most situations, but if \LaTeX\ is padding spaces, the difference can be more pronounced. This example may look exaggerated, but this is an accurate reflection of \LaTeX's spacing logic.

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-9-4}}
\end{center}

There are two commands that we can use to create and adjust spaces. The \verb|\hspace{}| command creates a horizontal space of the indicated size. This can be helpful when trying to create a specific spacing between words or equations. You can also combine the \verb|\hspace{}| command with an \verb|\underline| to create horizontal lines of specific length. I've used this to create lines for students to write their name at the top of a page or to create fill-in-the-blank questions.

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-9-5}}
\end{center}

The \verb|\vspace{}| command can be used to increase the space between paragraphs blocks, which can include things like centered text. I consider it as a way to make minor adjustments to the spacing for aesthetic purposes. If you try to use it in the middle of a paragraph, it probably won't behave the way you expect it to. Not that there's really a common need to do this in a middle of a paragraph, but it's just an example of how there are some things in \LaTeX\ that are more complicated than you might initially guess.

\begin{center}
  \fbox{\includegraphics[width=0.5\linewidth]{img-9-6}}
\end{center}

You can also create \texttt{phantom} characters. These are characters that take the same space as the normal character, except that they're invisible. This can be used for making spaces of a very specific size to line up text is a semi-tabular structure. In this example, the times on Saturday are lined up with each other, and the times on Sunday are lined up with each other, but the times across both dates are not. Here it is with the phantom text printed in light gray to show how we were able to get the perfect alignment.

\begin{center}
  \fbox{\includegraphics[width=0.85\linewidth]{img-9-7}}
\end{center}

There are a few more things we can do with the actual text of the document. In addition to the font styles we discussed earlier, there's also a small caps font. I've never had an application for it, but it's a fun one to know about.

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-9-8}}
\end{center}

In text mode, you can put a box around \LaTeX\ objects using \verb|\fbox{}|. In math mode, you can use the command \verb|\boxed{}|. This slide has some examples with boxed words and equations as a form of emphasis. Boxes can be put inside of other boxes, which would allow you to make an order of operations diagram. It turns out that boxes are one of the most basic elements of how \LaTeX\ does its typesetting magic. However, this can be an extremely overwhelming topic that isn't really necessary to dive into when you're in the early stages of learning. If you wanted to read more, there's a \href{https://en.wikibooks.org/wiki/LaTeX/Boxes}{link} in the description to an article that explains the core ideas in more detail.

\begin{center}
  \fbox{\includegraphics[width=0.85\linewidth]{img-9-9}}
\end{center}

There are times when you will want to create a visual separator between sections of a text. The \verb|\hrulefill| and the \verb|\dotfill| commands will fill out the remainder of a line of text with either a solid horizontal line or a series of dots. If you wanted to make this a standalone separator, you would just put this as its own paragraph. You will probably want to use \verb|\noindent| in front of it so that it covers the width of the entire page.

\begin{center}
  \fbox{\includegraphics[width=0.35\linewidth]{img-9-10}}
\end{center}

There is a more general command for creating lines like this is called \verb|\rule{}{}|. The first argument gives the horizontal length and the second gives the vertical length. The standard height for this is 0.4pt, but you can set it to be whatever you want. If you want to make it the width of the line, use the width \verb|\linewidth|. But you can also pick other lengths to create a custom-width separator.

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-9-11}}
\end{center}

Including graphics into \LaTeX\ documents has become fairly easy. The \href{https://ctan.org/pkg/graphicx}{\texttt{graphicx}} package has a command called \verb|\includegraphics{}|. There are many options for how you control the size of the image in the final product, but I generally stick to defining the width of the image because it's the most intuitive for me. You can specify either the width or the height, or use a percent of the line width, or even scale by a certain amount. If you specify just the width or just the height, \LaTeX\ will maintain the aspect ratio. If you specify both parameters, the image may get distorted.

This works with JPG, PNG, EPS, and PDF images. If your image is of a different type, you will need to convert it to one of these using either a drawing program or some online image converter.

As you go on to make longer and longer documents, there are a few things that you will want to be aware of. We have not touched the organizational structures that the article document class has available to us. We won't go into this too deeply, but it's important enough to at least mention and provide some examples for.

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-9-12}}
\end{center}

Every document can be embedded with information such as the title, date, and author. This information is all set in the preamble. Once that information is in place, \LaTeX\ can create a standard title with the command \verb|\maketitle| inside the document. You can also put formatting instructions inside these containers, such as a double backslash to create a new line or including images. If you don't include a date, it will automatically insert the compilation date. There's more that can be done with this, but we'll leave it at the basics.

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-9-13}}
\end{center}

The next structure that's useful to have are the sections, subsections, and subsubsections. This is something that is more important if you're writing an actual article and not just writing up short assignments. It's not a complicated system to use. Whenever you want to have a new subdivision of your document, you just tell \LaTeX\ with one of these commands. It will automatically create the various headers for you in the document and even keeps track of the numbering.

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-9-14}}
\end{center}

Once you start using these, you may also be interested in a table of contents. You can create a table of contents using the \verb|\tableofcontents| command. If you use this, you may need to compile your file a couple times. \LaTeX\ will first need to format the document and figure out how long each section is, and then it can go back and fill in the proper page numbers. You can control what appears in the table of contents by using an optional parameter between the level and the header title. 

I don't have a lot of advice for how to customize the table of contents because it's something I've never really done. But if you decide for some reason to have a table of contents and think the default isn't good enough for you, look for the \href{https://ctan.org/pkg/tocloft}{\texttt{tocloft}} package and read through the documentation to learn how to change it.

\begin{center}
  \fbox{\includegraphics[width=0.75\linewidth]{img-9-15}}
\end{center}

And as the document continues to get longer, you may want to start making internal references to equations and section numbers. This can be done with the \verb|\label{}| and \verb|\ref{}| commands. You can label many different objects, including sections, subsections, theorems, and equations. It is usually best to do this right when the object is created. This label creates a reference value based on whatever counter is being used for the object. It is a good habit to use a consistent labeling scheme that describes what you're labeling in order to avoid confusion, especially as the documents get longer.

\begin{center}
  \fbox{\includegraphics[width=0.85\linewidth]{img-9-16}}
\end{center}

To make a reference, you just use \verb|\ref{}|. This will automatically insert the value associated with the label. But it will only generate the number of the reference, and so you would have to explicitly type in reference in addition to calling the reference. This is also an excellent place to use a non-breaking space.

\begin{center}
  \fbox{\includegraphics[width=0.85\linewidth]{img-9-17}}
\end{center}

It's possible to make these references into hyperlinks using the \href{https://ctan.org/pkg/hyperref}{\texttt{hyperref}} package. If you just include the package, the table of contents will automatically be transformed into hyperlinks, as will all of your uses of \verb|\ref|. You will also have access to the \verb|\hyperref[]{}| command, which will allow you to link any reference with any text of your choice. If you want to make a reference without making it into a link, use the \verb|\ref*| command instead of \verb|\ref|. Incidentally, the \href{https://ctan.org/pkg/hyperref}{\texttt{hyperref}} package also has \verb|\href{}{}| for making hyperlinks to the internet.

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-9-18}}
\end{center}

Another thing you might choose to do is build your file in multiple documents. For example, you may choose to have a separate document for each section of your article. You can use the \verb|\input{}| and \verb|\include{}| commands to link to the contents of other documents. The \verb|\input{}| command literally just drops in the contents of the file as if you copy-pasted it in. The \verb|\include{}| command executes some code in the background and starts on a new page. It also has some extra restrictions, such as not being able to have nested levels of \verb|\include{}|.

This video is meant to give you a flavor of just how powerful \LaTeX\ can be. There's so much more that you can do beyond what you've seen in these videos. If you want to keep on going deeper, I would recommend \href{https://tobi.oetiker.ch/lshort/lshort.pdf}{\textit{The Not So Short Introduction to \LaTeX}}. It's only about 150 pages in length, and it goes into more detail on the core structures in \LaTeX\ than we covered here.

The next couple videos will be brief introductions to two important packages for using \LaTeX: \href{https://ctan.org/pkg/tikz}{\texttt{tikz}} and \href{https://ctan.org/pkg/beamer}{\texttt{beamer}}. \TikZ\ is used to create images and diagrams, and \href{https://ctan.org/pkg/beamer}{\texttt{beamer}} is a document class designed specifically for making presentation slides. Both are incredibly useful to become familiar with.